package com.lms.demo.autoconfigure.oss;

import com.aliyun.oss.OSS;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-12-25 15:37
 * @Description:
 */
@Configuration
@ConditionalOnMissingBean(OSSTemplate.class)
@ConditionalOnClass(OSS.class)
@EnableConfigurationProperties(OSSProperties.class)
@ConditionalOnProperty(name = "lms.oss.endpoint")
public class OSSTemplateAutoConfiguration {

    @Bean
    public OSSTemplate ossTemplate(OSSProperties ossProperties){
        return new OSSTemplate(ossProperties);
    }
}
